//
//  OrderdetailVC.m
//  phmall
//
//  Created by admin on 2017/12/15.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "RefundScheduleVC.h"
#import "OrderCell.h"
#import "OrderStatusView.h"
#import "OrderInformationView.h"

@interface RefundScheduleVC ()<UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate>{
    UIView *headerView;
}
@property(strong,nonatomic)UITableView *myTableview;

@end

@implementation RefundScheduleVC

-(void)butAction:(UIButton *)sender{
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"申请进度";
    
    UIBarButtonItem* leftBar=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarAction)];
    self.navigationItem.leftBarButtonItem=leftBar;
    
    [self.view addSubview:self.myTableview];
    [self.myTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(0);
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).with.offset(self.tabBar_height);
    }];

    //整体界面
    headerView=[UIView new];
    headerView.backgroundColor=[UIColor orangeColor];
    //轮播图
    
    UILabel *type=[[UILabel alloc]init];
    type.text=@"退款成功";
    type.textColor=[UIColor whiteColor];
    type.font=[UIFont systemFontOfSize:15];
    [headerView addSubview:type];
    [type mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.centerY.offset(0);
    }];
    
    //添加webview前计算一次高度
    CGRect frame = headerView.bounds;
    frame.size.height = 44;
    headerView.frame = frame;
    [self.myTableview setTableHeaderView:headerView];
    [headerView layoutIfNeeded];
    // Do any additional setup after loading the view.
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 2;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    //总高度
    return 54;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 82+10+44;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *nameView=[[UIView alloc]init];
    nameView.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView *back=[[UIView alloc]init];
    back.backgroundColor=[UIColor whiteColor];
    [nameView addSubview:back];
    [back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.offset(10);
    }];
    
    UILabel *name=[UILabel new];
    name.text=@"退款信息:";
    name.numberOfLines=2;
    name.font=[UIFont systemFontOfSize:15];
    [back addSubview:name];
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(back);
        make.left.offset(10);
    }];
    
    UILabel *line=[UILabel new];
    line.backgroundColor=[UIColor groupTableViewBackgroundColor];
    [nameView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(nameView.mas_bottom).offset(0);
        make.left.equalTo(nameView).with.offset(0);
        make.right.equalTo(nameView).with.offset(0);
        make.height.mas_equalTo(1);
    }];
    
    return nameView;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [[UIView alloc]init];
    footerView.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView *back=[[UIView alloc]init];
    back.backgroundColor=[UIColor whiteColor];
    [footerView addSubview:back];
    [back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
//        make.height.offset(82);
    }];
    
    UILabel *cause=[UILabel new];
    cause.text=@"退款原因:我不想买了";
    cause.font=[UIFont systemFontOfSize:13];
    cause.textColor=[UIColor colorWithHexString:@"#adadad"];
    [back addSubview:cause];
    [cause mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(back).offset(11);
        make.left.offset(10);
    }];
    UILabel *price=[UILabel new];
    price.text=@"退款金额(含运费):₱8888.80";
    price.textColor=[UIColor colorWithHexString:@"#adadad"];
    price.font=[UIFont systemFontOfSize:13];
    [back addSubview:price];
    [price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(cause.mas_bottom).offset(11);
        make.left.offset(10);
    }];
    
    UILabel *code=[UILabel new];
    code.text=@"退款原因:我不想买了";
    code.textColor=[UIColor colorWithHexString:@"#adadad"];
    code.font=[UIFont systemFontOfSize:13];
    [back addSubview:code];
    [code mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(price.mas_bottom).offset(11);
        make.left.offset(10);
        make.bottom.offset(-11);
    }];
    
    UIView *causeView=[[UIView alloc]init];
    causeView.backgroundColor=[UIColor whiteColor];
    [footerView addSubview:causeView];
    [causeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(footerView);
        make.top.equalTo(back.mas_bottom).offset(10);
        make.height.offset(44);
    }];
    
    UILabel *select=[[UILabel alloc]init];
    select.text=@"查看退款金额去向";
    select.font=[UIFont systemFontOfSize:12];
    [causeView addSubview:select];
    [select mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(causeView).offset(10);
        make.centerY.equalTo(causeView);
    }];
    
    UIImageView *img=[[UIImageView alloc]init];
    img.image=[UIImage imageNamed:@"前往"];
    [causeView addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(causeView).offset(-10);
        make.centerY.equalTo(causeView);
        make.height.offset(15);
        make.width.offset(15);
    }];
    
    UITapGestureRecognizer * causeTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
    causeTap.numberOfTouchesRequired = 1; //手指数
    causeTap.numberOfTapsRequired = 1; //tap次数
    causeTap.delegate= self;
    [causeView addGestureRecognizer:causeTap];
    return footerView;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    OrderCell *cell=[OrderCell theShareCellWithTableView:tableView];
    //    OrderModel *model=self.orderList[indexPath.section];
    //    NSMutableArray *data=model.goods_list;
    //    GoodsListModel *goodsModel=data[indexPath.row];
    //    cell.model=goodsModel;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //分割线补全
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}

//MARK:-GETTER
- (UITableView *)myTableview{
    if (!_myTableview) {
        _myTableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _myTableview.delegate = self;
        _myTableview.dataSource = self;
        _myTableview.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _myTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTableview.showsVerticalScrollIndicator=NO;
        _myTableview.scrollEnabled = YES;
    }
    return _myTableview;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

